<?php
    $tplabc = new XTemplate('sites/views/monhoc/edit.html');
    $id = $_GET['id'];
    $sql = "SELECT * FROM monhoc WHERE id=".$id;
    $data = $db->GetRow($sql);
    $name = $data['tenmonhoc'];
    if($_POST){
        $monhoc = $_POST['monhoc'];
        //print_r($monhoc);
        if(!$monhoc){
            echo "<script>alert('mon hoc khong duoc bo trong')</script>";
            $save = -1;
        }
        if($save != -1){
            
            $sql = "UPDATE monhoc SET tenmonhoc = '$monhoc' WHERE id=".$id;
            $db->Execute($sql);
            header("Location: index.php?m=monhoc&act=listall");
        }
    }
    $tplabc->assign('m_name',$name);
    $tplabc->parse('EDIT');
    $maincontent = $tplabc->text('EDIT');
?>